﻿using PHMEE.ToolKits;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PHMEE
{
    /// <summary>
    /// 主发电机
    /// </summary>
    public class MainGenerator : Equipment
    {
        protected MainGenerator()
        {

        }

        public MainGenerator(Guid id, Guid unitId, string name, string nameen, int number)
            : base(id, unitId, name, nameen, number)
        {

        }

        /// <summary>
        /// 相位
        /// </summary>
        [NotMapped]
        public double Phase { get; set; }

        /// <summary>
        /// 输出功率
        /// </summary>
        [NotMapped]
        public double Power { get; set; }

        /// <summary>
        /// 极数
        /// </summary>
        [NotMapped]
        public double Poles { get; set; }

        /// <summary>
        /// 额定电压
        /// </summary>
        [NotMapped]
        public double RatedVoltage { get; set; }

        /// <summary>
        /// 额定电流
        /// </summary>
        [NotMapped]
        public double RatedCurrent { get; set; }

        /// <summary>
        /// 频率
        /// </summary>
        [NotMapped]
        public double Frequency { get; set; }

        /// <summary>
        /// 功率因数
        /// </summary>
        [NotMapped]
        public double PowerFactor { get; set; }

        /// <summary>
        /// 防护等级
        /// </summary>
        [NotMapped]
        public string IpGrade { get; set; }

        /// <summary>
        /// 支撑方式
        /// </summary>
        [NotMapped]
        public SupportFlexibilityMode SupportFlexibilityMode { get; set; }

        /// <summary>
        /// 转动方式
        /// </summary>
        [NotMapped]
        public RotationMode RotationMode { get; set; }

        /// <summary>
        /// 基座类型
        /// </summary>
        [NotMapped]
        public ConnectMode ConnectMode { get; set; }

        public override void DeserializeProperties()
        {
            PHMEECoreHelper.SetDerivedProperties(this, DerivedPropertiesJson);
        }

        public override void SerializeProperties(Dictionary<string, object> derivedPropertiesJson)
        {
            var properties = PHMEECoreHelper.GetDerivedProperties(this);
            this.DerivedPropertiesJson = derivedPropertiesJson.Where(item => properties.Keys.Any(p => string.Equals(p, item.Key, StringComparison.OrdinalIgnoreCase))).ToDictionary();
        }
    }
}
